package com.flashflexpro.tanksinbattle.battlescene {
import com.flashflexpro.tanksinbattle.battlescene.dto.BattleSceneDto;
import com.flashflexpro.tanksinbattle.scene.AScene;

import flash.events.Event;

/**
 * before dispatch readyToStart, a battle scene needs to load skin, all sub modules
 */
[Event(name="moduleReady", type="flash.events.Event")]
public class BattleScene extends BattleSceneBase implements AScene{

    public function BattleScene(sceneDto:BattleSceneDto) {
        super(sceneDto);
    }

    private var _time:int;
    public function get time():int{
        return _time;
    }

    private var _userInputHandler:UserInputHandler;

    override protected function onAddedToStage(event:Event):void {
        super.onAddedToStage(event);
        _userInputHandler = new UserInputHandler( this );
    }

    private var _commands:Array = [];
    public function get commands():Array{
        return _commands;
    }


    public var paused:Boolean = false;

    override protected function onEnterFrame(event:Event):void {
        super.onEnterFrame(event);
        if( !paused ){
            update();
        }
    }

    private function update():void {
        _time ++;
        updateEach( time );
        checkHit();
    }

    override public function destroy():void {
        super.destroy();
        _userInputHandler.destroy();
    }
}
}